<?php

class InvoicesController extends Controller{
  public $layout='//layouts/main';
  
  public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}
  
  public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index', 'create', 'view'),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('admin','delete'),
				'users'=>array('admin'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}
  
	public function actionIndex()
	{
    $invoice = Invoices::model()->find('user_id = :user_id', array(':user_id' => $_SESSION['id']));
		$this->render('index', array(
      'invoice' => $invoice
    ));
	}
  
  public function actionCreate(){
    $this->redirect(bu("invoices"));
  }
  
  public function actionView($id){
  
  }
}